package com.tom.usercenter.common;

/**
 * 返回工具类
 */
public class ResultUtils {

    /**
     * 成功
     *
     * @param data
     * @param <T>
     * @return
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(ResultCodeEnum.SUCCESS, data);
    }


    /**
     * 失败
     *
     * @param code
     * @param message
     * @param description
     * @return
     */
    public static BaseResponse error(int code, String message) {
        return new BaseResponse(code, message,null);
    }

    /**
     * 失败
     *
     * @param errorCode
     * @return
     */
    public static BaseResponse error(ResultCodeEnum errorCode, String message, String description) {
        return new BaseResponse(errorCode.getCode(),  message,null);
    }


    /**
     * 失败
     *
     * @param errorCode
     * @return
     */
    public static <T> BaseResponse error(ResultCodeEnum errorCode,T data) {
        return new BaseResponse(errorCode.getCode(), errorCode.getMessage(), data   );
    }

}
